package com.chang.service.impl;

import com.chang.entity.Essay;
import com.chang.mapper.EssayMapper;
import com.chang.service.EssayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class EssayServiceImpl implements EssayService {

    @Autowired
    private EssayMapper essayMapper;

    /*添加推文*/
    @Override
    public int insertEssay(String title, String author, String content, Date time, String type) {
        return essayMapper.insertEssay(title,author,content,time,type);
    }

    /*查找所有的推文*/
    @Override
    public List<Essay> findAllEssay() {
        return essayMapper.findAllEssay();
    }

    @Override
    public List<Essay> findAllEssays() {
        return essayMapper.findAllEssay();
    }

    @Override
    public int updateEssay(int id, String title, String author, String content, Date time, String type) {
        return essayMapper.updateEssay(id,title,author,content,time,type);
    }

    @Override
    public boolean deleteEssay(int id) {
        return essayMapper.deleteEssay(id);
    }

    @Override
    public Essay checkEssay(String title, String author, String content, Date time, String type) {
        return essayMapper.checkEssay(title,author,content,time,type);
    }

    /*查找每一条推文的详细信息*/
    @Override
    public Essay findEachEssay(int essayId) {
        return essayMapper.findEachEssay(essayId);
    }
    @Override
    public Essay findEssayById(int id) {
        return essayMapper.findEssayById(id);
    }

    /*查找每一条推文的标题*/
    @Override
    public String findEssayTitle(int essayId) {
        return essayMapper.findEssayTitle(essayId);
    }

    /*miao*/
    @Override
    public Essay checkEssayByName(String title) {
        return essayMapper.checkEssayByName(title);
    }
}
